<?php
#----------------------------------------------------------------------------------------
#   Абстрактный класс CObject
#----------------------------------------------------------------------------------------
class CObject #abstract
{

#-------------------------------------------------------------------------------------------------------------------------
	var $error 		= 0;
	var $errors_str = array();
	var $debug		= 0;

#-------------------------------------------------------------------------------------------------------------------------

    function Free(){
		#emulate destructor =)
		$this->Destroy();
		#free class reference
		unset($this);
    }

#-------------------------------------------------------------------------------------------------------------------------

    function Destroy(){
		#abstract
		#rediclare in Inheriting if need =)

		#if you want make something when class destroying just rediclarete this function
    }

#-------------------------------------------------------------------------------------------------------------------------

    function ShowMass($mass, $name = ''){
		if ( !empty($name) )
		    print '<b>'.$name.'</b><br>';
		print "<pre>";
		print_r($mass);
		print "</pre>";
    }

#-------------------------------------------------------------------------------------------------------------------------

	function get_last_error(){
		return $this->error;
	}

#-------------------------------------------------------------------------------------------------------------------------

	function get_last_error_str(){
		return $this->errors_str[$this->error];
	}

#-------------------------------------------------------------------------------------------------------------------------

	function __raise_error( $error, $file = null, $line = null, $info = '' ){
		$res = '';
		$error_str = '';
		$this->error = $error;

		if( $this->error ){
			$res .= 'Raise Error ['.$this->error.'] => '.$this->get_last_error_str();
			if ( $this->debug ){
				if ( $file ) $res .= '<br><b>File => </b>'.$file;
				if ( $line ) $res .= '<br><b>Line => </b>'.$line;
				if ( $info ) $res .= '<br><b>Info => </b>'.$info;
				$res .= '<hr>';
			}
			$this->__error_report($res);
		}
	}

#-------------------------------------------------------------------------------------------------------------------------

	function __error_report($error_str){
		if ( trim($error_str) ){
			print "<br><b style='color:RED'>".$error_str."</b><br>";
			exit();
		}
	}

#-------------------------------------------------------------------------------------------------------------------------

	function GetMicrotime(){
		list($usec, $sec) = explode(" ",microtime());
		return (float)((float)$usec + (float)$sec);
	}

#-------------------------------------------------------------------------------------------------------------------------

}

?>